<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Goods extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('goods', ['engine' => 'InnoDB', 'comment' => '标品表', 'signed' => false]);
        $table->addColumn('cate_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '分类id', 'signed' => false])
                ->addColumn('brand_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '品牌id', 'signed' => false])
                ->addColumn('code69', 'string', ['limit' => 255, 'default' => '', 'comment' => '69码', 'collation' => 'utf8mb4_general_ci'])
                ->addColumn('name', 'string', ['limit' => 255, 'default' => '', 'comment' => '商品名称', 'collation' => 'utf8mb4_general_ci'])
                ->addColumn('image', 'string', ['limit' => 255, 'default' => '', 'comment' => '商品图片', 'collation' => 'utf8mb4_general_ci'])
                ->addColumn('shelf_life_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '保质期(天)', 'signed' => false])
                ->addColumn('warehouse_warn_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '入库预警(天)', 'signed' => false])
                ->addColumn('retention_warn_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '滞留预警(天)', 'signed' => false])
                ->addColumn('expiration_warn_day', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '过期预警(天)', 'signed' => false])
                ->addColumn('storage_condition', 'string', ['limit' => 255, 'default' => '', 'comment' => '存储条件', 'collation' => 'utf8mb4_general_ci'])
                ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'collation' => 'utf8mb4_general_ci'])
                ->addColumn('sort', 'integer', ['default' => 0, 'limit' => 10, 'comment' => '排序'])
                ->addColumn('status', 'integer', ['default' => 1, 'limit' => 1, 'comment' => '状态：1启用 2禁用'])
                ->addColumn('create_time', 'integer', ['default' => null, 'limit' => 10, 'comment' => '创建时间'])
                ->addColumn('update_time', 'integer', ['default' => null, 'limit' => 10, 'comment' => '更新时间'])
                ->addColumn('delete_time', 'integer', ['default' => null, 'limit' => 10, 'comment' => '删除时间'])
                ->addIndex('brand_id', ['name' => 'idx_brand_id'])
                ->addIndex('cate_id', ['name' => 'idx_cate_id'])
                ->addIndex('code69', ['name' => 'idx_code69'])
                ->create();
    }
}
